//联系人验证
export const person = (rule, value, callback) => {
   if(value ===  ""){
       callback(new Error('请输入联系人'))
   }else{
    callback();
   }
};

//电话号码验证
export const phonecode = (rule, value, callback) => {
    var re = /^[0-9]+.?[0-9]*$/
    var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
    var phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)|(\d{11})/;
    if(value ===  ""){
        callback(new Error('请输入联系电话'))
    }else{
        if(!re.test(value)){
            callback(new Error('请输入正确的联系电话')) 
        }else{
           if(value.length == 8&&!phone.test(value)){
            callback(new Error('号码格式不正确')) 
           }else if(
               value.length !== 11&&!mobile.test(value)
           ){
            callback(new Error('号码格式不正确')) 
           }
        }
     callback();
    }
 };
//申请车型验证
export const modetype = (rule, value, callback) => {
    if(value ===  ""){
        callback(new Error('请选择申请车型'))
    }else{
     callback();
    }
 };
//用车事由验证
export const reason = (rule, value, callback) => {
    if(value.length >= 50){
        callback(new Error('字数不能超过50'))
    }else{
     callback();
    }
 };

